package com.mcc.app.productionMat.controller;

import java.util.Date;
import java.util.List;
import com.mcc.common.utils.SecurityUtils;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mcc.common.annotation.Log;
import com.mcc.common.core.controller.BaseController;
import com.mcc.common.core.domain.AjaxResult;
import com.mcc.common.enums.BusinessType;
import com.mcc.app.productionMat.domain.RawMaterialCostAnalysis;
import com.mcc.app.productionMat.service.IRawMaterialCostAnalysisService;
import com.mcc.common.core.page.TableDataInfo;

/**
 * 原料成本分析
 *
 * @author gxy
 * @date 2025-03-21
 */
@Api(tags = "原料成本分析")
@RestController
@RequestMapping("/productionMat/analysis")
public class RawMaterialCostAnalysisController extends BaseController {

    @Autowired
    private IRawMaterialCostAnalysisService rawMaterialCostAnalysisService;

    @ApiOperation("查询原料成本分析列表")
    @ApiOperationSupport(order = 1)
    @PreAuthorize("@ss.hasPermi('productionMat:analysis:list')")
    @GetMapping("/list")
    public AjaxResult<TableDataInfo<RawMaterialCostAnalysis>> list(RawMaterialCostAnalysis rawMaterialCostAnalysis) {
        List<RawMaterialCostAnalysis> list = rawMaterialCostAnalysisService.selectRawMaterialCostAnalysisList(rawMaterialCostAnalysis);
        return getDataTable(list);
    }

    @ApiOperation("查询原料成本分析列表(分页)")
    @ApiOperationSupport(order = 2)
    @PreAuthorize("@ss.hasPermi('productionMat:analysis:list')")
    @GetMapping("/page")
    public AjaxResult<TableDataInfo<RawMaterialCostAnalysis>> page(RawMaterialCostAnalysis rawMaterialCostAnalysis) {
        startPage();
        List<RawMaterialCostAnalysis> list = rawMaterialCostAnalysisService.selectRawMaterialCostAnalysisList(rawMaterialCostAnalysis);
        return getDataTable(list);
    }

    @ApiOperation("获取原料成本分析详细信息")
    @ApiOperationSupport(order = 3)
    @PreAuthorize("@ss.hasPermi('productionMat:analysis:query')")
    @GetMapping("/get/{id}")
    public AjaxResult<RawMaterialCostAnalysis> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(rawMaterialCostAnalysisService.selectRawMaterialCostAnalysisById(id));
    }

    @ApiOperation("新增原料成本分析")
    @ApiOperationSupport(order = 4)
    @PreAuthorize("@ss.hasPermi('productionMat:analysis:add')")
    @Log(title = "原料成本分析", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody RawMaterialCostAnalysis rawMaterialCostAnalysis) {
        return toAjax(rawMaterialCostAnalysisService.insertRawMaterialCostAnalysis(rawMaterialCostAnalysis));
    }

    @ApiOperation("修改原料成本分析")
    @ApiOperationSupport(order = 5)
    @PreAuthorize("@ss.hasPermi('productionMat:analysis:edit')")
    @Log(title = "原料成本分析", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody RawMaterialCostAnalysis rawMaterialCostAnalysis) {
        return toAjax(rawMaterialCostAnalysisService.updateRawMaterialCostAnalysis(rawMaterialCostAnalysis));
    }

    @ApiOperation("删除原料成本分析")
    @ApiOperationSupport(order = 6)
    @PreAuthorize("@ss.hasPermi('productionMat:analysis:remove')")
    @Log(title = "原料成本分析", businessType = BusinessType.DELETE)
	@PostMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(rawMaterialCostAnalysisService.deleteRawMaterialCostAnalysisByIds(ids));
    }
}
